<?php
namespace Dianpu\Controller;

class LoginController extends \Hdphp\Controller\Controller {
//	public function login() {
//
//		$shop = Db::table('shop') -> where('id',$_POST['id']) -> where('password', $_POST['password']) -> first();
//		if ($shop) {
//			$_SESSION['dpid'] = $_POST['id'];
//			View::ajax(array('code' => 0, 'message' => '登录成功'));
//		} else {
//			View::ajax(array('code' => 1, 'message' => '登录失败'));
//		}
//	}


	public function login() {
		if (IS_POST) {
			$shop = Db::table('shop') -> where('id', $_POST['id']) -> where('password', $_POST['password']) -> first();
			if ($shop) {
				$_SESSION['dpid'] = $_POST['id'];
				go("Index/index");
				
			} else {
				View::error('登录失败');
			}
		} else {
			$data = Db::table('shop') -> where('wxid', $_GET['wxid']) -> get();
			$sid['sid']=$_GET['id'];
			View::with('data', $data);
			View::with('sid',$sid);
			View::make();
		}
	}
}
